package com.example.score.controller;


import com.example.score.dto.AjaxResult;
import com.example.score.dto.questionFile.ExamQuestionFileDTO;
import com.example.score.entity.ExamQuestionFile;
import com.example.score.service.ExamQuestionFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 */
@Slf4j
@RestController
@RequestMapping("/api/exam/question/file")
public class ExamQuestionFileController {

    @Autowired
    private ExamQuestionFileService examQuestionFileService;

    /**
     * 附件列表
     */
    @GetMapping("/list")
    public AjaxResult list(ExamQuestionFileDTO examQuestionFileDTO) {
        List<ExamQuestionFile> examQuestionFileList = examQuestionFileService.list(examQuestionFileDTO);
        return AjaxResult.success(examQuestionFileList);
    }

    /**
     * 新增附件
     */
    @PostMapping
    public AjaxResult add(@RequestBody ExamQuestionFile examQuestionFile)
    {
        return examQuestionFileService.add(examQuestionFile) > 0 ? AjaxResult.success() : AjaxResult.error();
    }


    /**
     * 删除附件
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return examQuestionFileService.delete(ids) > 0 ? AjaxResult.success() : AjaxResult.error();
    }
}
